package com.wgy.blog.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wgy.blog.common.Result;
import com.wgy.blog.mapper.ArticleMapper;
import com.wgy.blog.pojo.Article;
import com.wgy.blog.service.ArticleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author:Iny
 * @Data：2021/11/19 23:18
 */
@Service
public class ArticleServiceImpl implements ArticleService {

    @Resource
    private ArticleMapper articleMapper;
    @Override
    public Result<List<Article>> findAll(PageInfo pageInfo) {
        PageHelper.startPage(pageInfo.getPageNum(),pageInfo.getPageSize());
        List<Article> articleList = articleMapper.findAll();
        PageInfo<Article> articlePageInfo = new PageInfo<>(articleList);
        return Result.success((int) articlePageInfo.getTotal(),articlePageInfo.getList());
    }

    @Override
    public Result update(Article article) {
        return null;
    }

    @Override
    public Result add(Article article) {
        return null;
    }

    @Override
    public Result deleteSortNav(int id) {
        return null;
    }
}
